﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;

namespace BLL
{
    public class ForAddition
    {
        //添加管理员
        public string AddAdmin(string manageID, string pwd)
        {
            string message;
            string sql1 = "select ManageID from Admin where ManageID='"+manageID+"'";
            string sql2 = "insert into Admin (ManageID, Pwd) values("+ manageID + ","+ pwd + ");";
            DBHelper.ConnectionOpen();
            if (DBHelper.ExecuteScalar(sql1) != null)
            {
                message = "无法添加同名的用户，请重新输入！";
                DBHelper.ConnectionClose();
                return message;
            }
            else
            {
                try
                {
                    int jg = DBHelper.ExecuteNonQuery(sql2);
                    if (jg > 0)
                    {
                        message = "添加成功！";
                        return message;
                    }
                    else
                    {
                        message = "添加失败！";
                        return message;
                    }
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                finally
                {
                    DBHelper.ConnectionClose();
                }
            }
        }
    }
}
